package com.airagg.custom.gson;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.http.converter.json.GsonHttpMessageConverter;

/**
 * Created by Administrator on 2017/4/4.
 */
public class GsonCustomConverter extends GsonHttpMessageConverter {

    public GsonCustomConverter() {
        Gson gson = new GsonBuilder()
                .enableComplexMapKeySerialization() //支持Map的key为复杂对象的形式
                .serializeNulls()
                .setDateFormat("yyyy-MM-dd HH:mm:ss")//时间转化为特定格式
                .setPrettyPrinting()
                .setVersion(1.0)
                .create();
        super.setGson(gson);
        this.setDefaultCharset(DEFAULT_CHARSET);
    }

}
